All Questions
Tagged with programming-challengerecursion
77 questions
5votes
3answers
959views
LeetCode 678: Valid Parenthesis String, Recursion memoization to DP
How can the following recursion + memoization code be converted into a tabulation format dynamic programming solution? The code is working, but I want to improve it. The challenge I am facing is ...
2votes
3answers
553views
Recursive palindrome check
I'm trying to solve this which basically calls for a recursive palindrome check with some minor extra steps (Special characters and whitespace can be ignored). The test inputs' length can be 100000 ...
2votes
2answers
250views
Generate the number of partitions of each integer
I've coded a program that calculates the number of partitions of n into at least two distinct parts, and is relatively quick too (about N^1.5 complexity). For input 30 000 it takes roughly 4 seconds. ...
4votes
0answers
165views
Finding the number of possible paths in a cave system (Python)
I've finally come up with working solution for day 12 of AdventOfCode, where you have to find the number of possible paths in a cave system following a given set of rules (described below). My ...
1vote
0answers
372views
Codewars: Path Finder
Task You are at position [0, 0] in maze NxN and you can only move in one of the four cardinal directions (i.e. North, East, South, West). Return true if you can reach position [N-1, N-1] or false ...
3votes
1answer
231views
Killing a Hydra - Overengineered
Background This question is inspired by the question: Killing a hydra, and my response therein. I will restate the problem at hand in full so that this question is fully self contained You can only ...
1vote
1answer
252views
"Sequence full of colors" challenge on HackerRank
This is the challenge: You are given a sequence of N balls in 4 colors: red, green, yellow and blue. The sequence is full of colors if and only if all of the ...
3votes
0answers
314views
LeetCode: Stone Game C#
https://leetcode.com/problems/stone-game/ Alex and Lee play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of stones ...
5votes
1answer
273views
Hackerrank: Breaking the records
I'm learning Clojure and am a rank n00b at it, trying to learn from books and online tutorials (but I'm sometimes concerned that I am picking up bad habits or at least not all the good habits). For ...
1vote
2answers
247views
Recursive brute-force approach to maximum points you can obtain from cards
I came across this question on Leetcode. The question description is as follows: There are several cards arranged in a row, and each card has an associated number of points. The points are given in ...
9votes
1answer
944views
Number in words: recursive function
I would appreciate some feedback on the below code I wrote for a Project Euler problem. The answer comes out correct but I'd like feedback on the design of the function and implementation of ...
7votes
2answers
1kviews
Letter Combinations of a phone number using a Dictionary
Problem statement (online source) Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone ...
2votes
0answers
103views
Leetcode Finding Maximum Area of Island Solution
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are ...
4votes
2answers
194views
Code Challenge: basic arithmic operations using only incrementation operator
Challenge Write a function that takes 2 integer operands left and right (both >= 0) and evaluates one of the following basic ...
3votes
1answer
567views
Find A Series of Numbers Who when Squared and Summed are equal to a given Square
I am working on a CodeWars titled 'Square into Squares. Protect trees!' it can be found here: https://www.codewars.com/kata/54eb33e5bc1a25440d000891/train/javascript I have a working solution, the ...